package Controls
{
	import Load.DataFormat;
	import Load.LoadData;
	import Load.MixedLoad;
	
	import Objects.GameBitmap;
	import Objects.GameObject;
	import Objects.GameSprite;
	
	import flash.display.Bitmap;
	import flash.display.DisplayObject;
	import flash.system.LoaderContext;

	public class Image extends GameBitmap
	{
		private var lastUrl:String="";
		public function Image()
		{
			super();
		}
		public function load(url:String,context:LoaderContext=null):void
		{
			if(lastUrl==url)return;
			
			lastUrl=url;
			
			var loadData:LoadData=new LoadData();
			loadData.url=url;
			loadData.context=context;
			loadData.dataFormat=DataFormat.IMAGE;
			MixedLoad.load([loadData],finish);
		}
		public function finish(loadData:LoadData):void
		{
			var image:Bitmap=loadData.data as Bitmap;
			if(image)
			{
				setImage(image.bitmapData);
			}
		}
	}
}